package cz.muni.fi.pb138.gscholarinfo.classes;

import java.util.Collections;
import java.util.List;
import java.util.LinkedList;

public class AuthorPublications {
    private Author author;
    private List<Publication> publications;
    
    public AuthorPublications() {
        this.publications = new LinkedList<Publication>();
    }
    
    public AuthorPublications(Author author) {
        this.author = author;
        this.publications = new LinkedList<Publication>();
    }

    public Author getAuthor() {
        return this.author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public List<Publication> getPublications() {
        return Collections.unmodifiableList(publications);
    }

    public void addPublication(Publication publication) {
        if (publication != null)
            this.publications.add(publication);
    }
    
    @Override
    public String toString() {
        String ret = this.author.getName() + " : {" + System.getProperty("line.separator");
        for (Publication item : this.publications)
            ret += item.toString() + System.getProperty("line.separator");
        
        ret += "}" + System.getProperty("line.separator");
        
        return ret;
    }
}
